<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.jpg">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.jpg">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"matian.connorma.cn","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="在开发的任务调度平台中，任务执行日志分布在各个机器上，希望用户可以无感知的查看任务的执行日志内容。但日志的数量、大小较大，统一存储将带来较大的存储压力；使用任务执行器后端程序读取指定日志文件并在API响应中返回，这种方式可定制程度最高，在许多的大数据、任务调度开源项目中使用了这种方式实现。 本文将介绍另一种简单易行的方式，使用nginx代理静态日志文件，通过lua脚本读取日志文件的指定行并返回；这">
<meta property="og:type" content="article">
<meta property="og:title" content="nginx+lua(OpenResty)实现代理日志文件指定行读取">
<meta property="og:url" content="http://matian.connorma.cn/e6a6b472.html">
<meta property="og:site_name" content="马天">
<meta property="og:description" content="在开发的任务调度平台中，任务执行日志分布在各个机器上，希望用户可以无感知的查看任务的执行日志内容。但日志的数量、大小较大，统一存储将带来较大的存储压力；使用任务执行器后端程序读取指定日志文件并在API响应中返回，这种方式可定制程度最高，在许多的大数据、任务调度开源项目中使用了这种方式实现。 本文将介绍另一种简单易行的方式，使用nginx代理静态日志文件，通过lua脚本读取日志文件的指定行并返回；这">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-01-06T00:41:24.000Z">
<meta property="article:modified_time" content="2024-01-25T12:19:17.208Z">
<meta property="article:author" content="马天">
<meta property="article:tag" content="nginx">
<meta property="article:tag" content="OpenResty">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://matian.connorma.cn/e6a6b472.html">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>nginx+lua(OpenResty)实现代理日志文件指定行读取 | 马天</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">马天</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://matian.connorma.cn/e6a6b472.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="马天">
      <meta itemprop="description" content="程序猿">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="马天">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          nginx+lua(OpenResty)实现代理日志文件指定行读取
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-01-06 08:41:24" itemprop="dateCreated datePublished" datetime="2023-01-06T08:41:24+08:00">2023-01-06</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/nginx/" itemprop="url" rel="index"><span itemprop="name">nginx</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>在开发的任务调度平台中，任务执行日志分布在各个机器上，希望用户可以无感知的查看任务的执行日志内容。但日志的数量、大小较大，统一存储将带来较大的存储压力；使用任务执行器后端程序读取指定日志文件并在API响应中返回，这种方式可定制程度最高，在许多的大数据、任务调度开源项目中使用了这种方式实现。</p>
<p>本文将介绍另一种简单易行的方式，使用nginx代理静态日志文件，通过lua脚本读取日志文件的指定行并返回；这种方式需要每台任务执行器所在的机器都提供一个nginx代理，希望只对外暴露一个入口的话那么可以在这些nginx节点之上再增加一层nginx代理，按照节点IP路由。或者，可以通过NFS等方式将日志文件写到网络文件地址中，这样只需要一个nginx读取NFS的共享文件，大量写入的情况下NFS的稳定性、读写性能是否会存在问题？其实按照之前的实际经历，大数据平台任务的shuffle数据写入NFS&#x2F;Ceph，难免会出现性能下降或者IO的“毛刺”等诸多问题，不过对一般的任务调度系统相信并不会达到这种写入量级，其实大可以放心使用。</p>
<p>本文主要将介绍使用nginx+lua实现指定读取日志行的实现，其他问题我们略过，诸位若想尝试可自行验证。</p>
<p>另外，nginx可以在编译时加入lua模块来支持lua脚本，但其实可以直接使用OpenResty（ngx_openresty，<a target="_blank" rel="noopener" href="https://github.com/openresty/openresty">github地址在这里</a>），内置了nginx，支持进行嵌入lua编程脚本，并扩展了大量的第三方模块，使得nginx不仅可用于静态代理，也完全可以通过各类module作为通用型的web应用服务器使用。本文将直接使用OpenResty来实现。</p>
<span id="more"></span>

<h2 id="OpenResty的安装"><a href="#OpenResty的安装" class="headerlink" title="OpenResty的安装"></a>OpenResty的安装</h2><p>本文在centos7系统上进行安装，使用源代码模式在centos7&#x2F;ubuntu18.04快速安装可以参考<a target="_blank" rel="noopener" href="https://gitee.com/connormma/quick_launch_tools/blob/master/nginx/linux_amd64/openresty_install.sh">此脚本</a></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">curl https://openresty.org/package/centos/openresty.repo &gt; /etc/yum.repos.d/openresty.repo</span><br><span class="line">yum install -y openresty</span><br><span class="line">yum install -y openresty-resty</span><br></pre></td></tr></table></figure>
<p>默认openresty将安装到&#x2F;usr&#x2F;local&#x2F;openresty下，在&#x2F;usr&#x2F;local&#x2F;openresty下可以看到nginx目录，即是openresty内置的nginx，我们将nginx可执行文件添加到PATH中：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">echo &#x27;export PATH=$PATH:/usr/local/openresty/nginx/sbin&#x27; &gt;&gt; /etc/profile</span><br><span class="line">source /etc/profile</span><br><span class="line">nginx  -V</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启动nginx</span></span><br><span class="line">nginx</span><br></pre></td></tr></table></figure>

<p>安装完成后nginx的配置文件路径为：&#x2F;usr&#x2F;local&#x2F;openresty&#x2F;nginx&#x2F;conf</p>
<h2 id="nginx-lua代理日志文件读取指定行"><a href="#nginx-lua代理日志文件读取指定行" class="headerlink" title="nginx+lua代理日志文件读取指定行"></a>nginx+lua代理日志文件读取指定行</h2><p>约定日志文件都在&#x2F;opt&#x2F;worker&#x2F;logs这一目录下，为了方便演示，我们直接将nginx的日志软链到这一路径下</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ln -s /usr/local/openresty/nginx/logs /opt/worker/logs</span><br></pre></td></tr></table></figure>

<p>nginx对外暴露的location为&#x2F;logs，使用端口80，以下location即为日志文件进行了静态代理</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">location /logs &#123;</span><br><span class="line">    alias /opt/worker/logs;</span><br><span class="line">    default_type &#x27;text/plain; charset=utf-8&#x27;;</span><br><span class="line">    add_header Access-Control-Allow-Origin *;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>浏览器打开 <a target="_blank" rel="noopener" href="http://localhost/logs/access.log">http://localhost/logs/access.log</a> 即可以查看access.log文件内容</p>
<p>接下来我们逐步完善lua脚本，依次实现在lua脚本中读取url携带的路径的文件并返回内容；按入参http请求携带的tail参数值，读取文件指定的tail行，tail为负数时，读取所有行。</p>
<h3 id="创建与引用lua脚本"><a href="#创建与引用lua脚本" class="headerlink" title="创建与引用lua脚本"></a>创建与引用lua脚本</h3><p>创建lua脚本：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/local/openresty/nginx/conf</span><br><span class="line">mkdir scripts</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">scripts/tail_file.lua</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">hello world，ngx.say的内容将输出到http response中</span></span><br><span class="line">echo &#x27;ngx.say(&#x27;hello world&#x27;)&#x27; &gt;&gt; scripts/tail_file.lua</span><br></pre></td></tr></table></figure>

<p>在nginx location中引用这一脚本：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">location /logs &#123;</span><br><span class="line">    default_type &#x27;text/plain; charset=utf-8&#x27;;</span><br><span class="line">    add_header Access-Control-Allow-Origin *;</span><br><span class="line">    content_by_lua_file /usr/local/openresty/nginx/conf/scripts/tail_file.lua;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>nginx -s reload重新加载配置后，我们访问 <a target="_blank" rel="noopener" href="http://localhost/logs/access.log">http://localhost/logs/access.log</a> 页面将显示’hello world’</p>
<h3 id="lua脚本输出文件所有内容"><a href="#lua脚本输出文件所有内容" class="headerlink" title="lua脚本输出文件所有内容"></a>lua脚本输出文件所有内容</h3><p>接下来我们修改lua脚本，读取url携带的路径的文件的全部内容并返回：</p>
<figure class="highlight lua"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 将url地址替换为服务器真实文件路径</span></span><br><span class="line"><span class="keyword">local</span> uri = ngx.var.uri</span><br><span class="line"><span class="comment">-- 第四个参数指定1，限制替换1次</span></span><br><span class="line"><span class="keyword">local</span> fpath = <span class="built_in">string</span>.<span class="built_in">gsub</span>(uri, <span class="string">&quot;/logs&quot;</span>, <span class="string">&quot;/opt/worker/logs&quot;</span>, <span class="number">1</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 读取文件全部内容</span></span><br><span class="line"><span class="keyword">local</span> f = <span class="built_in">io</span>.<span class="built_in">open</span>(fpath, <span class="string">&quot;r&quot;</span>)</span><br><span class="line"><span class="comment">-- 文件不存在时，返回404</span></span><br><span class="line"><span class="keyword">if</span> f == <span class="literal">nil</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    ngx.<span class="built_in">status</span> = <span class="number">404</span></span><br><span class="line">    ngx.say(<span class="string">&quot;file not found&quot;</span>)</span><br><span class="line">    ngx.<span class="built_in">exit</span>(ngx.OK)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="keyword">local</span> content = f:<span class="built_in">read</span>(<span class="string">&quot;*all&quot;</span>)</span><br><span class="line">f:<span class="built_in">close</span>()</span><br><span class="line">ngx.say(content)</span><br></pre></td></tr></table></figure>

<h3 id="lua脚本输出文件指定行内容"><a href="#lua脚本输出文件指定行内容" class="headerlink" title="lua脚本输出文件指定行内容"></a>lua脚本输出文件指定行内容</h3><p>我们在lua中读取http请求携带的tail参数值，读取文件指定的尾部n行，tail为负数时，读取所有行。</p>
<p>读取文件尾部的n行，我们可以使用lua脚本lines()逐行读取文件，通过滑动窗口丢弃掉不需要的行。</p>
<p>这里我们选取了通过lua调用shell命令获取文件尾部n行的方式：</p>
<figure class="highlight lua"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 将url地址替换为服务器真实文件路径</span></span><br><span class="line"><span class="keyword">local</span> uri = ngx.var.uri</span><br><span class="line"><span class="comment">-- 第四个参数指定1，限制替换1次</span></span><br><span class="line"><span class="keyword">local</span> fpath = <span class="built_in">string</span>.<span class="built_in">gsub</span>(uri, <span class="string">&quot;/logs&quot;</span>, <span class="string">&quot;/opt/worker/logs&quot;</span>, <span class="number">1</span>)</span><br><span class="line"><span class="comment">-- 文件不存在时，返回404</span></span><br><span class="line"><span class="keyword">local</span> f = <span class="built_in">io</span>.<span class="built_in">open</span>(fpath, <span class="string">&quot;r&quot;</span>)</span><br><span class="line"><span class="keyword">if</span> f == <span class="literal">nil</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    ngx.<span class="built_in">status</span> = <span class="number">404</span></span><br><span class="line">    ngx.say(<span class="string">&quot;file not found&quot;</span>)</span><br><span class="line">    ngx.<span class="built_in">exit</span>(ngx.OK)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">local</span> tail = ngx.var.arg_tail</span><br><span class="line"><span class="comment">-- tail约定合法值范围为：非零整数</span></span><br><span class="line"><span class="keyword">if</span> <span class="built_in">tonumber</span>(tail) == <span class="number">0</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    ngx.<span class="built_in">status</span> = <span class="number">400</span></span><br><span class="line">    ngx.say(<span class="string">&quot;arg tail should not be 0&quot;</span>)</span><br><span class="line">    ngx.<span class="built_in">exit</span>(ngx.OK)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="comment">-- tail默认为10</span></span><br><span class="line"><span class="keyword">if</span> tail == <span class="literal">nil</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    tail = <span class="number">10</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 调用shell获取文件尾部n行</span></span><br><span class="line"><span class="comment">-- 拼接cmd</span></span><br><span class="line"><span class="keyword">local</span> cmd = <span class="string">&#x27;tail -n &#x27;</span> .. tail .. <span class="string">&#x27;  &#x27;</span> .. fpath</span><br><span class="line"><span class="comment">-- 执行cmd并读取执行结果</span></span><br><span class="line"><span class="keyword">local</span> handle = <span class="built_in">io</span>.<span class="built_in">popen</span>(cmd)</span><br><span class="line"><span class="keyword">local</span> result = handle:<span class="built_in">read</span>(<span class="string">&quot;*a&quot;</span>)</span><br><span class="line">handle:<span class="built_in">close</span>()</span><br><span class="line"><span class="comment">-- 输出结果</span></span><br><span class="line">ngx.say(content)</span><br></pre></td></tr></table></figure>

<p>为了脚本逻辑清晰，我们使用function抽取部分逻辑：</p>
<figure class="highlight lua"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 调用shell读取文件尾部tail行</span></span><br><span class="line"><span class="keyword">local</span> <span class="function"><span class="keyword">function</span> <span class="title">tail_file</span><span class="params">(fpath, tail)</span></span></span><br><span class="line">  <span class="comment">-- 调用shell获取文件尾部n行</span></span><br><span class="line">  <span class="comment">-- 拼接cmd</span></span><br><span class="line">  <span class="keyword">local</span> cmd = <span class="string">&#x27;tail -n &#x27;</span> .. tail .. <span class="string">&#x27;  &#x27;</span> .. fpath</span><br><span class="line">  <span class="comment">-- 执行cmd并读取执行结果</span></span><br><span class="line">  <span class="keyword">local</span> handle = <span class="built_in">io</span>.<span class="built_in">popen</span>(cmd)</span><br><span class="line">  <span class="keyword">local</span> content = handle:<span class="built_in">read</span>(<span class="string">&quot;*a&quot;</span>)</span><br><span class="line">  handle:<span class="built_in">close</span>()</span><br><span class="line">  <span class="keyword">return</span> content</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 读取文件全部内容</span></span><br><span class="line"><span class="keyword">local</span> <span class="function"><span class="keyword">function</span> <span class="title">read_file</span><span class="params">(fpath)</span></span></span><br><span class="line">    <span class="comment">-- 读取文件全部内容</span></span><br><span class="line">    <span class="keyword">local</span> f = <span class="built_in">io</span>.<span class="built_in">open</span>(fpath, <span class="string">&quot;r&quot;</span>)</span><br><span class="line">    <span class="keyword">local</span> content = f:<span class="built_in">read</span>(<span class="string">&quot;*all&quot;</span>)</span><br><span class="line">    <span class="keyword">return</span> content</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 将url地址替换为服务器真实文件路径</span></span><br><span class="line"><span class="keyword">local</span> uri = ngx.var.uri</span><br><span class="line"><span class="comment">-- 第四个参数指定1，限制替换1次</span></span><br><span class="line"><span class="keyword">local</span> fpath = <span class="built_in">string</span>.<span class="built_in">gsub</span>(uri, <span class="string">&quot;/logs&quot;</span>, <span class="string">&quot;/opt/worker/logs&quot;</span>, <span class="number">1</span>)</span><br><span class="line"><span class="comment">-- 文件不存在时，返回404</span></span><br><span class="line"><span class="keyword">local</span> f = <span class="built_in">io</span>.<span class="built_in">open</span>(fpath, <span class="string">&quot;r&quot;</span>)</span><br><span class="line"><span class="keyword">if</span> f == <span class="literal">nil</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    ngx.<span class="built_in">status</span> = <span class="number">404</span></span><br><span class="line">    ngx.say(<span class="string">&quot;file not found&quot;</span>)</span><br><span class="line">    ngx.<span class="built_in">exit</span>(ngx.OK)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">local</span> tail = ngx.var.arg_tail</span><br><span class="line"><span class="comment">-- tail约定合法值范围为：非零整数</span></span><br><span class="line"><span class="keyword">if</span> <span class="built_in">tonumber</span>(tail) == <span class="number">0</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    ngx.<span class="built_in">status</span> = <span class="number">400</span></span><br><span class="line">    ngx.say(<span class="string">&quot;arg tail should not be 0&quot;</span>)</span><br><span class="line">    ngx.<span class="built_in">exit</span>(ngx.OK)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="comment">-- tail默认为10</span></span><br><span class="line"><span class="keyword">if</span> tail == <span class="literal">nil</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    tail = <span class="number">10</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- tail为正数时，读取文件尾部n行；tail为负数时，读取文件全部内容</span></span><br><span class="line"><span class="keyword">local</span> result = <span class="string">&#x27;&#x27;</span></span><br><span class="line"><span class="keyword">if</span> <span class="built_in">tonumber</span>(tail) &gt; <span class="number">0</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    result = tail_file(fpath, tail)</span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">    result = read_file(fpath)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="comment">-- 输出结果</span></span><br><span class="line">ngx.say(result)</span><br></pre></td></tr></table></figure>

<p>此时，打开 <a target="_blank" rel="noopener" href="http://localhost/logs/access.log">http://localhost/logs/access.log</a> 将返回文件尾部10行内容；打开 <a target="_blank" rel="noopener" href="http://localhost/logs/access.log?tail=5">http://localhost/logs/access.log?tail=5</a> 将返回文件尾部5行内容；打开 <a target="_blank" rel="noopener" href="http://localhost/logs/access.log?tail=-1">http://localhost/logs/access.log?tail=-1</a> 将返回文件全部内容</p>
<h2 id="安全性问题的思考"><a href="#安全性问题的思考" class="headerlink" title="安全性问题的思考"></a>安全性问题的思考</h2><p>在上文中，我们将用户输入的url地址添加前缀后作为服务器实际文件路径读取文件内容，在使用shell读取时，直接将路径拼接到命令中：</p>
<figure class="highlight lua"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">local</span> cmd = <span class="string">&#x27;tail -n &#x27;</span> .. tail .. <span class="string">&#x27;  &#x27;</span> .. fpath</span><br></pre></td></tr></table></figure>

<p>这里我们不难想到，如果用户在url中输入 .. ~ 等代表路径的字符串，或者通过引号&#x2F;反引号等（’,”,&#96;,$）注入shell指令，那么就可能成功读取到服务器任意文件内容，或者执行任意指令</p>
<p>这里我并没有进行验证，但是不得不考虑这类情况，简单处理的话，可以在lua脚本中加入一段字符合法性检查进行过滤：</p>
<figure class="highlight lua"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 调用shell读取文件尾部tail行</span></span><br><span class="line"><span class="keyword">local</span> <span class="function"><span class="keyword">function</span> <span class="title">tail_file</span><span class="params">(fpath, tail)</span></span></span><br><span class="line">  <span class="comment">-- 调用shell获取文件尾部n行</span></span><br><span class="line">  <span class="comment">-- 拼接cmd</span></span><br><span class="line">  <span class="keyword">local</span> cmd = <span class="string">&#x27;tail -n &#x27;</span> .. tail .. <span class="string">&#x27;  &#x27;</span> .. fpath</span><br><span class="line">  <span class="comment">-- 执行cmd并读取执行结果</span></span><br><span class="line">  <span class="keyword">local</span> handle = <span class="built_in">io</span>.<span class="built_in">popen</span>(cmd)</span><br><span class="line">  <span class="keyword">local</span> content = handle:<span class="built_in">read</span>(<span class="string">&quot;*a&quot;</span>)</span><br><span class="line">  handle:<span class="built_in">close</span>()</span><br><span class="line">  <span class="keyword">return</span> content</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 读取文件全部内容</span></span><br><span class="line"><span class="keyword">local</span> <span class="function"><span class="keyword">function</span> <span class="title">read_file</span><span class="params">(fpath)</span></span></span><br><span class="line">    <span class="comment">-- 读取文件全部内容</span></span><br><span class="line">    <span class="keyword">local</span> f = <span class="built_in">io</span>.<span class="built_in">open</span>(fpath, <span class="string">&quot;r&quot;</span>)</span><br><span class="line">    <span class="keyword">local</span> content = f:<span class="built_in">read</span>(<span class="string">&quot;*all&quot;</span>)</span><br><span class="line">    <span class="keyword">return</span> content</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- url输入路径是否合法</span></span><br><span class="line"><span class="keyword">local</span> <span class="function"><span class="keyword">function</span> <span class="title">is_legal_url</span><span class="params">(uri)</span></span></span><br><span class="line">    <span class="comment">-- find函数指定第四个参数为true，表示搜索的字符串为纯文本，默认false表示pattern匹配</span></span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">string</span>.<span class="built_in">find</span>(uri, <span class="string">&quot;..&quot;</span>, <span class="number">1</span>, <span class="literal">true</span>)</span><br><span class="line">    <span class="keyword">then</span></span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span></span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">string</span>.<span class="built_in">find</span>(uri, <span class="string">&quot;~&quot;</span>, <span class="number">1</span>, <span class="literal">true</span>)</span><br><span class="line">    <span class="keyword">then</span></span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span></span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">string</span>.<span class="built_in">find</span>(uri, <span class="string">&quot;`&quot;</span>, <span class="number">1</span>, <span class="literal">true</span>)</span><br><span class="line">    <span class="keyword">then</span></span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span></span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">string</span>.<span class="built_in">find</span>(uri, <span class="string">&quot;&#x27;&quot;</span>, <span class="number">1</span>, <span class="literal">true</span>)</span><br><span class="line">    <span class="keyword">then</span></span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span></span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">string</span>.<span class="built_in">find</span>(uri, <span class="string">&quot;\&quot;&quot;</span>, <span class="number">1</span>, <span class="literal">true</span>)</span><br><span class="line">    <span class="keyword">then</span></span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span></span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">string</span>.<span class="built_in">find</span>(uri, <span class="string">&quot;$&quot;</span>, <span class="number">1</span>, <span class="literal">true</span>)</span><br><span class="line">    <span class="keyword">then</span></span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span></span><br><span class="line">    <span class="keyword">end</span></span><br><span class="line">    <span class="keyword">return</span> <span class="literal">true</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 将url地址替换为服务器真实文件路径</span></span><br><span class="line"><span class="keyword">local</span> uri = ngx.var.uri</span><br><span class="line"><span class="keyword">if</span> <span class="keyword">not</span> is_legal_url(uri)</span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    ngx.<span class="built_in">status</span> = <span class="number">400</span></span><br><span class="line">    ngx.say(<span class="string">&quot;uri not legal&quot;</span>)</span><br><span class="line">    ngx.<span class="built_in">exit</span>(ngx.OK)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 第四个参数指定1，限制替换1次</span></span><br><span class="line"><span class="keyword">local</span> fpath = <span class="built_in">string</span>.<span class="built_in">gsub</span>(uri, <span class="string">&quot;/logs&quot;</span>, <span class="string">&quot;/opt/worker/logs&quot;</span>, <span class="number">1</span>)</span><br><span class="line"><span class="comment">-- 文件不存在时，返回404</span></span><br><span class="line"><span class="keyword">local</span> f = <span class="built_in">io</span>.<span class="built_in">open</span>(fpath, <span class="string">&quot;r&quot;</span>)</span><br><span class="line"><span class="keyword">if</span> f == <span class="literal">nil</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    ngx.<span class="built_in">status</span> = <span class="number">404</span></span><br><span class="line">    ngx.say(<span class="string">&quot;file not found&quot;</span>)</span><br><span class="line">    ngx.<span class="built_in">exit</span>(ngx.OK)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">local</span> tail = ngx.var.arg_tail</span><br><span class="line"><span class="comment">-- tail约定合法值范围为：非零整数</span></span><br><span class="line"><span class="keyword">if</span> <span class="built_in">tonumber</span>(tail) == <span class="number">0</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    ngx.<span class="built_in">status</span> = <span class="number">400</span></span><br><span class="line">    ngx.say(<span class="string">&quot;arg tail should not be 0&quot;</span>)</span><br><span class="line">    ngx.<span class="built_in">exit</span>(ngx.OK)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="comment">-- tail默认为10</span></span><br><span class="line"><span class="keyword">if</span> tail == <span class="literal">nil</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    tail = <span class="number">10</span></span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- tail为正数时，读取文件尾部n行；tail为负数时，读取文件全部内容</span></span><br><span class="line"><span class="keyword">local</span> result = <span class="string">&#x27;&#x27;</span></span><br><span class="line"><span class="keyword">if</span> <span class="built_in">tonumber</span>(tail) &gt; <span class="number">0</span></span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">    result = tail_file(fpath, tail)</span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">    result = read_file(fpath)</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"><span class="comment">-- 输出结果</span></span><br><span class="line">ngx.say(result)</span><br></pre></td></tr></table></figure>

<p>通过加入一段字符过滤逻辑，限制url不能存在 .. ~ ‘ “ &#96; $ 等字符。在此之外，继续加入了以下限制，逻辑并不复杂大家自行实现：限制nginx的启动用户和lua脚本中调用shell命令使用的用户（su - asafeuser -c “cmd here”），将lua中具备读取权限的文件限制在部分路径下。</p>
<p>但是安全加固是一门高深、有相当壁垒的学问，加上了以上措施我相信也并不会完全安全，最终只是在测试环境中限制了内网访问。</p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/nginx/" rel="tag"># nginx</a>
              <a href="/tags/OpenResty/" rel="tag"># OpenResty</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/660efd9a.html" rel="prev" title="bitmap与布隆过滤器">
      <i class="fa fa-chevron-left"></i> bitmap与布隆过滤器
    </a></div>
      <div class="post-nav-item">
    <a href="/e72717fd.html" rel="next" title="三方应用接入与OAuth的思考">
      三方应用接入与OAuth的思考 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#OpenResty%E7%9A%84%E5%AE%89%E8%A3%85"><span class="nav-number">1.</span> <span class="nav-text">OpenResty的安装</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#nginx-lua%E4%BB%A3%E7%90%86%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%E8%AF%BB%E5%8F%96%E6%8C%87%E5%AE%9A%E8%A1%8C"><span class="nav-number">2.</span> <span class="nav-text">nginx+lua代理日志文件读取指定行</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%88%9B%E5%BB%BA%E4%B8%8E%E5%BC%95%E7%94%A8lua%E8%84%9A%E6%9C%AC"><span class="nav-number">2.1.</span> <span class="nav-text">创建与引用lua脚本</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#lua%E8%84%9A%E6%9C%AC%E8%BE%93%E5%87%BA%E6%96%87%E4%BB%B6%E6%89%80%E6%9C%89%E5%86%85%E5%AE%B9"><span class="nav-number">2.2.</span> <span class="nav-text">lua脚本输出文件所有内容</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#lua%E8%84%9A%E6%9C%AC%E8%BE%93%E5%87%BA%E6%96%87%E4%BB%B6%E6%8C%87%E5%AE%9A%E8%A1%8C%E5%86%85%E5%AE%B9"><span class="nav-number">2.3.</span> <span class="nav-text">lua脚本输出文件指定行内容</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%89%E5%85%A8%E6%80%A7%E9%97%AE%E9%A2%98%E7%9A%84%E6%80%9D%E8%80%83"><span class="nav-number">3.</span> <span class="nav-text">安全性问题的思考</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">马天</p>
  <div class="site-description" itemprop="description">程序猿</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">41</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">17</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">25</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/matian2014" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;matian2014" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:matian1103@qq.com" title="E-Mail → mailto:matian1103@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">陕ICP备2023001563号 </a>
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2025</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">马天</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
